package com.wfm.leetcode.editor.cn;

/**
 * 搜索二维矩阵 II
 * 2025-02-26 14:59:00
 */
class SearchA2dMatrixIi {

    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public boolean searchMatrix(int[][] matrix, int target) {
        int m = matrix.length , n= matrix[0].length;
        int i = 0 , j = n-1;
        while (i < m && j >= 0){
            if (matrix[i][j] == target){
                return true;
            }
            if (matrix[i][j] > target){
                j--;
            }else {
                i++;
            }
        }
        return false;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

    public static void main(String[] args) {
        Solution solution = new SearchA2dMatrixIi().new Solution();
        
    }
}